import 'dart:convert';

class RegisterResponse {
  final Data? data;
  final int? resultCode;
  final String? resultMsg;
  final int? queryCount;
  final dynamic resultMsgEx;

  RegisterResponse({
    this.data,
    this.resultCode,
    this.resultMsg,
    this.queryCount,
    this.resultMsgEx,
  });

  factory RegisterResponse.fromJson(Map<String, dynamic> json) {
    return RegisterResponse(
      data: Data.fromJson(json['data'] ?? Map()),
      // data: Data.fromJson(jsonDecode(json['data'] ?? '{}')),
      resultCode: json['resultCode'] ?? int,
      resultMsg: json['resultMsg'] ?? '',
      queryCount: json['queryCount'] ?? int,
      resultMsgEx: json['resultMsgEx'] ?? '',
    );
  }
}

class Data {
  final String? accessToken;
  final String? authTime;
  final String? expiresAt;
  final int? expiredIn;
  final User? user;

  Data({
     this.accessToken,
     this.authTime,
     this.expiresAt,
     this.expiredIn,
     this.user,
  });

  factory Data.fromJson(Map<String, dynamic> json) {
    return Data(
      accessToken: json['accessToken'] ?? '',
      authTime: json['authTime'] ?? '',
      expiresAt: json['expiresAt'] ?? '',
      expiredIn: json['expiredIn'] ?? -1,
      user: User.fromJson(json['user'] ?? Map()),
      // user: User.fromJson(jsonDecode(json['user'] ?? '{}')),
    );
  }
}

class User {
  final String? userId;
  final String? wxUnionId;
  final String? flyUnionId;

  User({
    this.userId,
    this.wxUnionId,
    this.flyUnionId,
  });

  factory User.fromJson(Map<String, dynamic> json) {
    return User(
      userId: json['userId'] ?? '',
      wxUnionId: json['wxUnionId'] ?? '',
      flyUnionId: json['flyUnionId'] ?? '',
    );
  }
}


